//
//  OutstandingController.swift
//  ExpressDriver
//
//  Created by sheng on 2017/11/15.
//  Copyright © 2017年 sheng. All rights reserved.
//

import UIKit

class OutstandingController: UIViewController {
    
    
    @IBOutlet weak var segmented: UISegmentedControl!
    
    @IBOutlet weak var orderListView: UIView!
    
    @IBOutlet weak var orderMapView: UIView!
    
    let statusHeight = UIApplication.shared.statusBarFrame.height
    let scrrenHeight = UIScreen.main.bounds.height
    let scrrenWidth = UIScreen.main.bounds.width
    

    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
        self.view.backgroundColor = UIColor.white
        
        //setUI();
        let navigHeight = self.navigationController!.navigationBar.frame.height
        let height = statusHeight + navigHeight + 30 + 15 + 15
        
        segmented.snp.makeConstraints { (make) in
            make.top.equalTo(statusHeight + navigHeight + 15)
            make.width.equalTo((scrrenWidth * 2)/3)
            make.height.equalTo(30)
            make.centerX.equalTo(self.view)
        }
        
        
        orderListView.backgroundColor = UIColor.green
        orderListView.snp.makeConstraints { (make) in
            make.top.equalTo(segmented.snp.bottom).offset(15)
            make.left.right.equalTo(0)
            make.width.equalTo(scrrenWidth)
            make.height.equalTo(scrrenHeight - height)
        }
        
        orderMapView.snp.makeConstraints { (make) in
            make.top.equalTo(segmented.snp.bottom).offset(15)
            make.left.right.equalTo(0)
            make.width.equalTo(scrrenWidth)
            make.height.equalTo(scrrenHeight - height)
        }
        
        segmented.selectedSegmentIndex = 0
        orderListView.isHidden = false
        orderMapView.isHidden = true
    }
    
    
    
    
    
    
    @IBAction func segmentedIndexChanged(_ sender: UISegmentedControl) {
        switch sender.selectedSegmentIndex {
        case 0:
            orderListView.isHidden = false
            orderMapView.isHidden = true
        case 1:
            orderListView.isHidden = true
            orderMapView.isHidden = false
        default:
            break;
        }
    }
    
    
    
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

   

}
